#@layout()
#define script()
<script>

    $.ajax({
        url: "http://47.105.208.60:8080/wechat-api/Blind_date/findAllNo?pagenum=1"
        //url: "http://localhost:8080/wechat-api/Blind_date/findAllNo?pagenum=1"
        , dataType: 'json'
        , type: 'get'
        , success: function (data) {
            console.log("+++++++")
            console.log(data);
            if (data != null && data != "") {
                var infos = data.list;
                $("tbody").html("");
                $(infos).each(function () {
                    var content = "<tr id='tr' class='tr'>";
                    content += "<td>" + this.enname + "</td>";
                    content += "<td>" + this.name + "</td>";
                    content += "<td>" + this.citys + "</td>";
                    content += "<td>" + this.info9 + "</td>";
                    content += "<td><button onclick='add(\"" + this.id + "\")'>发放结亲证书</button></td>";
                    content += "</tr>";
                    $("tbody").append($(content));

                })
            } else {
                console.log("========")
                alert("操作失败");//请求传输失败回调函数
            }
        }
        , error: function (msg) {
            console.log("----------")
            alert("ajax错误"); //错误信息

        }
    });

    function no() {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/Blind_date/findAllNo?pagenum=1"
            //url: "http://localhost:8080/wechat-api/Blind_date/findAllNo?pagenum=1"
            , dataType: 'json'
            , type: 'get'
            , success: function (data) {
                console.log("+++++++")
                console.log(data);
                if (data != null && data != "") {
                    $("tbody").html("");
                    var infos = data.list;
                    $(infos).each(function () {
                        var content = "<tr id='tr' class='tr'>";
                        content += "<td>" + this.enname + "</td>";
                        content += "<td>" + this.name + "</td>";
                        content += "<td>" + this.citys + "</td>";
                        content += "<td>" + this.info9 + "</td>";
                        content += "<td><button onclick='add(\"" + this.id + "\")'>发放结亲证书</button></td>";
                        content += "</tr>";
                        $("tbody").append($(content));

                    })
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert("ajax错误"); //错误信息

            }
        });
    }

    function yes() {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/Blind_date/findAllYes?pagenum=1"
            //url: "http://localhost:8080/wechat-api/Blind_date/findAllYes?pagenum=1"
            , dataType: 'json'
            , type: 'get'
            , success: function (data) {
                console.log("+++++++")
                console.log(data);
                if (data != null && data != "") {
                    $("tbody").html("");
                    var infos = data.list;
                    $(infos).each(function () {
                        var content = "<tr id='tr' class='tr'>";
                        content += "<td>" + this.enname + "</td>";
                        content += "<td>" + this.name + "</td>";
                        content += "<td>" + this.citys + "</td>";
                        content += "<td>" + this.info9 + "</td>";
                        content += "<td><button onclick='update(\"" + this.id + "\")'>修改证书编号</button></td>";
                        content += "</tr>";
                        $("tbody").append($(content));

                    })
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert("没有数据"); //错误信息

            }
        });
    }

    function add(id) {
        window.open("#(CPATH)/admin/certificate/add?id=" + id, "newwindow123", "height=550, width=950, top=100, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");

    }

    function update(id) {
        window.open("#(CPATH)/admin/certificate/add?id=" + id, "newwindow123", "height=550, width=950, top=100, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");

    }

    $("form").submit(function () {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/Blind_date/findlike"
            //url: "http://localhost:8080/wechat-api/Blind_date/findlike"
            , data: $("form").serialize()
            , dataType: 'json'
            , type: 'get'
            , success: function (data) {
                console.log("+++++++")
                console.log(data);
                if (data.code == 0) {
                    $("tbody").html("");
                    var infos = data.info;
                    $(infos).each(function () {
                        var content = "<tr id='tr' class='tr'>";
                        content += "<td>" + this.enname + "</td>";
                        content += "<td>" + this.name + "</td>";
                        content += "<td>" + this.citys + "</td>";
                        content += "<td>" + this.info9 + "</td>";
                        if (this.info9 != '0') {
                            content += "<td><button onclick='update(\"" + this.id + "\")'>修改证书编号</button></td>";
                        } else {
                            content += "<td><button onclick='add(\"" + this.id + "\")'>发放结亲证书</button></td>";
                        }
                        content += "</tr>";
                        $("tbody").append($(content));

                    })
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert("没有数据"); //错误信息

            }
        })
    })

</script>

#end

#define content()
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            结亲家庭管理
            <!--<small>Article Management</small>-->
        </h1>
    </section>

    <section class="content-header text-tap">
    </section>

    <section class="content">

        <div class="row">
            <div class="box box-primary">
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                <label>
                    <button onclick="no()">未发放结亲证书</button>
                </label>
                &nbsp; &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp;
                <label>
                    <button onclick="yes()">已发放结亲证书</button>
                </label>
            </div>
            <div>
                <form onsubmit="return false" style="margin-left: 200px">
                    <input type="text" name="enname" placeholder="请输入农户名称"/>
                    &nbsp;&nbsp;&nbsp;
                    <input type="submit" value="查询"/>
                </form>
            </div>
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-body ">

                        <table class="table table-striped">
                            <thead>
                            <th>结亲农户</th>
                            <th>结亲人</th>
                            <th>结亲人所在地</th>
                            <th>证书编号</th>
                            <th>操作</th>
                            </thead>
                            <tbody>

                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <div class="row">
                            <div class="col-sm-12">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>

    </section>


</div>
#end
